﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Control_SalaryInfonew : System.Web.UI.UserControl
{
    private Srvtools.WebDataSet WMasterSalary;
    private int _eid;
    private bool _readonly;
    protected void Page_Load(object sender, EventArgs e)
    {
        

        if (!IsPostBack)
        {
            wnSalary.Visible = !ReadOnly;

            InitializeComponent(false);

            WMasterSalary.SetWhere("EmployeeId=" + Eid);
            MasterSalary.DataSource = WMasterSalary;


            //int i = WMasterSalary.GetRecordsCount();

            
        }
    }

  

    public int Eid
    {
        get
        {
            return _eid;
        }
        set
        {
            _eid = value;
        }
    }

    public bool ReadOnly
    { 
        get
        {
            return _readonly;
        }
        set
        {
            _readonly = value;
        }
    }



    private void InitializeComponent(bool action)
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Control_SalaryInfonew));
        this.WMasterSalary = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMasterSalary)).BeginInit();
        // 
        // WMasterSalary
        // 
        this.WMasterSalary.Active = action;
        this.WMasterSalary.AlwaysClose = true;
        this.WMasterSalary.DataCompressed = false;
        this.WMasterSalary.DeleteIncomplete = true;
        this.WMasterSalary.Guid = null;
        this.WMasterSalary.LastKeyValues = null;
        this.WMasterSalary.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMasterSalary.PacketRecords = 100;
        this.WMasterSalary.Position = -1;
        this.WMasterSalary.RemoteName = "SEmployees.EmployeesSalary";
        this.WMasterSalary.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMasterSalary)).EndInit();

    }


    protected void wnSalary_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "cmdFirst" || e.CommandName == "cmdPrevious"
            || e.CommandName == "cmdNext" || e.CommandName == "cmdLast")
        {
            MasterSalary.ExecuteSelect(FVSalary);
            DataBind();
        }
        else if (e.CommandName == "cmdAdd")
        {
            MasterSalary.ExecuteAdd(FVSalary);
            DataBind();
        }
        else if (e.CommandName == "cmdDelete")
        {
            MasterSalary.ExecuteSelect(FVSalary);
            DataBind();
        }
        else if (e.CommandName == "cmdApply" && FVSalary.AllValidateSucess)
        {
            MasterSalary.ExecuteSelect(FVSalary);
            DataBind();
        }

    }

    protected void updateContract_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        Response.Redirect("ContractDetail.aspx?eid=" + lb.CommandArgument + "&redurl=" + Server.UrlEncode(Request.Url.ToString()) + "&ename=" + lb.CommandName);
    }


    protected void showContract_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        Response.Redirect("ContractDetail.aspx?eid=" + lb.CommandArgument + "&redurl=" + Server.UrlEncode(Request.Url.ToString()) + "&ename=" + lb.CommandName + "&action=view");
    }
}
